package com.sofwin.configer;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @packageName: com.sofwin.configer
 * @user: andyliu
 * @date: 2023/1/6 11:31
 * @email 115176513@qq.com
 * @description: TODO
 */
@Configuration
public class KaptchaConfiger {
    @Bean
    public DefaultKaptcha defaultKaptcha(){
        DefaultKaptcha kaptcha = new DefaultKaptcha();
        Properties props = new Properties();
        props.setProperty("kaptcha.border","yes");
        props.setProperty("kaptcha.border.color","105,179,90");
        props.setProperty("kaptcha.textproducer.font.color","blue");
        props.setProperty("kaptcha.image.width","110");
        props.setProperty("kaptcha.image.height","32");
        props.setProperty("kaptcha.textproducer.font.size","25");
        props.setProperty("kaptcha.textproducer.char.length","4");
        props.setProperty("kaptcha.textproducer.font.names","宋体,楷体,微软雅黑");
        Config config = new Config(props);

        kaptcha.setConfig(config);

        return kaptcha;
    }
}
